<?php
/**
 * 品牌中心功能类文件
 * @author		Arthur(ArthurXF@gmail.com)
 * @copyright	(c) 2006 by bizeway.com
 * @version		$Id$
 * @package		ArthurXF
 * @subpackage	brand
 */

class brand extends ArthurXF{
	public $thisModel = 'brand';
	public $tablename3 = 'product';
	public $tablename4 = 'product_type';

	/**
	 * 根据产品类型取得相关品牌
	 * @author	肖飞
	 * @param	string $strProductTypeTitle    产品类型标题
	 * @return  void
	 */
	function getBrandWithProductType($type){
		$strSQL = "select title,initial,id from $this->tablename2 where id in (select brand_id from $this->tablename3 where type_id='".$type."')";
		$rs = $this->db->query($strSQL);
		$arrData = $rs->fetchall();
		return $arrData;
	}

	/**
	 * 获取品牌列表数据并取得产品数目
	 * @author	肖飞
	 * @return  array
	 */
	function getInfoListWithCount($where=""){
		if (!empty($where))	$where = "WHERE " . $where;
		$strSQL = "SELECT t1. * , count( t2.id ) AS count
					FROM $this->tablename2 AS t1
					LEFT JOIN $this->tablename3 AS t2 ON t1.id = t2.brand_id
					$where
					GROUP BY t1.id
					ORDER BY t1.type_id,t1.initial,t1.sort DESC ";
		$rs = $this->db->query($strSQL);
		$arrData = $rs->fetchall();
		return $arrData;
	}

}
?>